package com.ruoyi.reserve.service.impl;


import com.ruoyi.reserve.domain.CheckGroup;
import com.ruoyi.reserve.domain.Setmeal;
import com.ruoyi.reserve.domain.SetmealCheckGroup;
import com.ruoyi.reserve.mapper.SetmealMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class SetmealServiceImpl implements ISetmealService {

    @Autowired
    private SetmealMapper setmealMapper;


    //    查询所有
    @Override
    public List<Setmeal> selectSetmealList(Setmeal setmeal) {
        return setmealMapper.selectSetmealList(setmeal);
    }

    //    批量删除
    @Override
    public int deleteSetmeal(Integer[] itemsId) {
        return setmealMapper.deleteSetmeal(itemsId);
    }

    //    添加
    @Override

    public int insertSetmeal(Setmeal setmeal) {
        return setmealMapper.insertSetmeal(setmeal);
    }

    //   修改时的查询   根据id获取该条检查项的详情
    @Override
    public Setmeal getInfo(Integer id) {
        return setmealMapper.getInfo(id);
    }

    //  修改
    @Override
    public int updateSetmeal(Setmeal setmeal) {
        return setmealMapper.updateSetmeal(setmeal);
    }

    /**
     * 新增时 根据编号查询检查项是否存在
     */
    @Override
    public Setmeal getInfoByCode(String code) {
        return setmealMapper.getInfoByCode(code);
    }

    /**
     * 新增时 根据名称查询检查项是否存在
     */
    @Override
    public Setmeal getInfoByName(String mealName) {
        return setmealMapper.getInfoByName(mealName);
    }

    /**
     * 通过套餐删除其中的检查组
     * @param setmeal
     * @param setmealCheckGroupList
     * @return
     */
    @Override
    public int deleteGroupSetmealByIds(Integer setmeal, List<SetmealCheckGroup> setmealCheckGroupList) {
        return setmealMapper.deleteGroupSetmealByIds(setmeal,setmealCheckGroupList);
    }

    // 获取可以被该套餐新增的检查组集合
    @Override
    public List<CheckGroup> getAddSetmealList(Setmeal setmeal) {
        return setmealMapper.getAddSetmealList(setmeal);
    }

    /**
     * 新增检查组到套餐中去
     * @param setmealCheckGroupList 添加进去的检查组集合
     * @return
     */
    @Override
    public int insertGroupSetmealByIds(List<SetmealCheckGroup> setmealCheckGroupList) {
        return setmealMapper.insertGroupSetmealByIds(setmealCheckGroupList);
    }
}
